package com.wealth.wechat.web.controller;


import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.wealth.member.entity.Member;
import com.wealth.member.entity.Membership;
import com.wealth.member.service.IMemberService;
import com.wealth.member.service.IMembershipService;
import com.wealth.system.web.controller.BaseController;

/**
 * @author chan
 */
@Controller
@RequestMapping("/getopenid")
public class GetOpenIdContrller extends BaseController{

	Logger logger = Logger.getLogger(GetOpenIdContrller.class);
	@Autowired
	private IMemberService iMemberService;
	@Autowired IMembershipService iMembershipService;
	/** 
	 * 主页入口 静默获取
	 */
	@RequestMapping(value="")
	public String indexEntry(HttpServletRequest request,Model model) {
		try {
			String reqUrl=request.getParameter("reqUrl");
			Member member = iMemberService.get(memberid);
			Membership ship =  iMembershipService.getMemberShipByMemberIdAndCorpId(memberid, corpid);
			String openid = ship.getOpenid();
			String headimg= member.getHeadimgurl();
			String nickname = member.getNickname();
			model.addAttribute("openid",openid );
			model.addAttribute("headimg",headimg );
			model.addAttribute("nickname",nickname );
			model.addAttribute("memberid",memberid );
			model.addAttribute("reqUrl", reqUrl);
			String scopeEnum=  request.getParameter("scopeEnum");
			model.addAttribute("scopeEnum", scopeEnum);
			return "lottery/test";
		} catch (Exception e) {
			return "system/500";
		}
   }

	
}
